const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')

// 导入 tools, 根据 process.env.locale 来动态显示 index.html 模板的 title 属性.
const { getIndexTitleWithLocale } = require('./webpack.cross.tools')

module.exports = {
  entry: path.resolve(__dirname, './src/index.js'),
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, './dist')
  },
  plugins: [
    new HtmlWebpackPlugin({
      // 动态指定模板 title,不能使用 template 属性
      // template: path.resolve(__dirname),
      title: getIndexTitleWithLocale()
    }),
    new CleanWebpackPlugin()
  ]
}
